//
//  AppTools.m
//  BonweBuy
//
//  Created by liuxin on 2020/2/24.
//  Copyright © 2020 liuxin. All rights reserved.
//

#import "AppTools.h"

@implementation AppTools

#pragma mark - 根据名称获取json文件数据
+ (NSDictionary *)readLocalFileWithName:(NSString *)name
{
    // 获取文件路径
    NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"json"];
    // 将文件数据化
    NSData *data = [[NSData alloc] initWithContentsOfFile:path];
    
    return [NSJSONSerialization JSONObjectWithData:data
                                           options:kNilOptions
                                             error:nil];
}

#pragma mark - 不会丢失进度的转换
+(NSString *)getStringWithDouble:(double)doubleValue{
    NSString *amountDoubleStr = [NSString stringWithFormat:@"%lf", doubleValue];
    NSDecimalNumber *amountNum = [NSDecimalNumber decimalNumberWithString:amountDoubleStr];
    NSString *amountStr = [amountNum stringValue];
    return amountStr;
}

@end
